﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.DataAnnotations;
using Iesi.Collections;
using System.Web.Script.Serialization;
using Iesi.Collections.Generic;

namespace DomainModel.Entities
{
    // script [ScriptIgnore] will not output data into JSON Data
    public class Event
    {
        public virtual int EventID { get; set; }

        public virtual int UserID { get; set; }

        public virtual int EditedBy { get; set; }

        [Required(ErrorMessage = "Title is required.")]
        public virtual string Title { get; set; }

        public virtual DateTime DateEvent { get; set; }

        [Required(ErrorMessage = "Description is required.")]
        public virtual string Description { get; set; }

        [Required(ErrorMessage = "Contact is required.")]
        public virtual string ContactPhone { get; set; }

        [Required(ErrorMessage = "Address is required.")]
        public virtual string Address { get; set; }

        public virtual float Latitude { get; set; }

        public virtual float Longitude { get; set; }

        public virtual DateTime DateUpdated { get; set; }

        public virtual DateTime DateEditedBy { get; set; }


        [ScriptIgnore]
        public virtual User User { get; set; }

        // many to one (many) - many users to one event
        [ScriptIgnore]
        public virtual IList<User> RSVPUsers { get; set; }

        // one to many - one event to many comments
        [ScriptIgnore]
        private ISet commentsList = new HashedSet();
        [ScriptIgnore]
        public ISet CommentsList
        {
            get { return commentsList; }
            set { commentsList = value; }
        }

        // one to many - one event to many Tags
        [ScriptIgnore]
        private ISet tagsList = new HashedSet();
        [ScriptIgnore]
        public ISet TagsList
        {
            get { return tagsList; }
            set { tagsList = value; }
        }

        public void AddTag(Tag tag)
        {
            TagsList.Add(tag);
        }


        // one to many - one event to many Tags
        [ScriptIgnore]
        private ISet ratesList = new HashedSet();
        [ScriptIgnore]
        public ISet RatesList
        {
            get { return ratesList; }
            set { ratesList = value; }
        }

        public void AddRate(Rate rate)
        {
            RatesList.Add(rate);
        }

        [ScriptIgnore]
        [Required(ErrorMessage = "one tag is required.")]
        public string TagString { get; set; }



    }

}
